(function(a){
var d={every:function(h){
"use strict";
if(this===void 0||this===null)
throw new TypeError();
var l=Object(this);
var k=l.length>>>0;
if(typeof h!=="function")
throw new TypeError();
var m=arguments[1];
for(var j=0;j<k;j++)
{
if(j in l&&!h.call(m,l[j],j,l))
{
return false;
}
}
return true;
},filter:function(h){
"use strict";
if(this===void 0||this===null)
throw new TypeError();
var m=Object(this);
var k=m.length>>>0;
if(typeof h!=="function")
throw new TypeError();
var l=[];
var n=arguments[1];
for(var j=0;j<k;j++)
{
if(j in m)
{
var o=m[j];
if(h.call(n,o,j,m))
l.push(o);
}
}
return l;
},forEach:function(h){
"use strict";
if(this===void 0||this===null)
throw new TypeError();
var l=Object(this);
var k=l.length>>>0;
if(typeof h!=="function")
throw new TypeError();
var m=arguments[1];
for(var j=0;j<k;j++)
{
if(j in l)
h.call(m,l[j],j,l);
}
},indexOf:function(l){
"use strict";
if(this===void 0||this===null)
throw new TypeError();
var m=Object(this);
var i=m.length>>>0;
if(i===0)
{
return -1;
}
var j=0;
if(arguments.length>0)
{
j=Number(arguments[1]);
if(j!==j)
j=0;
else if(j!==0&&j!==(Infinity)&&j!==-(Infinity))
j=(j>0||-1)*Math.floor(Math.abs(j));
}
if(j>=i)
{
return -1;
}
var h=j>=0?j:Math.max(i-Math.abs(j),0);
for(;h<i;h++)
{
if(h in m&&m[h]===l)
{
return h;
}
}
return -1;
},lastIndexOf:function(l){
"use strict";
if(this===void 0||this===null)
throw new TypeError();
var m=Object(this);
var i=m.length>>>0;
if(i===0)
{
return -1;
}
var j=i;
if(arguments.length>1)
{
j=Number(arguments[1]);
if(j!==j)
j=0;
else if(j!==0&&j!==(Infinity)&&j!==-(Infinity))
j=(j>0||-1)*Math.floor(Math.abs(j));
}
var h=j>=0?Math.min(j,i-1):i-Math.abs(j);
for(;h>=0;h--)
{
if(h in m&&m[h]===l)
{
return h;
}
}
return -1;
},map:function(h){
"use strict";
if(this===void 0||this===null)
throw new TypeError();
var m=Object(this);
var k=m.length>>>0;
if(typeof h!=="function")
throw new TypeError();
var l=new Array(k);
var n=arguments[1];
for(var j=0;j<k;j++)
{
if(j in m)
l[j]=h.call(n,m[j],j,m);
}
return l;
},reduce:function(i){
"use strict";
if(this===void 0||this===null)
throw new TypeError();
var m=Object(this);
var l=m.length>>>0;
if(typeof i!=="function")
throw new TypeError();
if(l==0&&arguments.length==1)
throw new TypeError();
var j=0;
var h;
if(arguments.length>=2)
{
h=arguments[1];
}
else{
do{
if(j in m)
{
h=m[j++];
break;
}
if(++j>=l)
throw new TypeError();
}
while(true);
}
while(j<l)
{
if(j in m)
h=i.call(undefined,h,m[j],j,m);
j++;
}
return h;
},reduceRight:function(i){
"use strict";
if(this===void 0||this===null)
throw new TypeError();
var m=Object(this);
var l=m.length>>>0;
if(typeof i!=="function")
throw new TypeError();
if(l===0&&arguments.length===1)
throw new TypeError();
var j=l-1;
var h;
if(arguments.length>=2)
{
h=arguments[1];
}
else{
do{
if(j in this)
{
h=this[j--];
break;
}
if(--j<0)
throw new TypeError();
}
while(true);
}
while(j>=0)
{
if(j in m)
h=i.call(undefined,h,m[j],j,m);
j--;
}
return h;
},some:function(h){
"use strict";
if(this===void 0||this===null)
throw new TypeError();
var l=Object(this);
var k=l.length>>>0;
if(typeof h!=="function")
throw new TypeError();
var m=arguments[1];
for(var j=0;j<k;j++)
{
if(j in l&&h.call(m,l[j],j,l))
{
return true;
}
}
return false;
},groupBy:function(k){
var j={},i=this;
var h=$.isFunc(k)?k:function(l){
return l[k];
};
e.forEach(i,function(n,l){
var m=h(n,l);
(j[m]||(j[m]=[])).push(n);
});
return j;
}};
var f=Array.prototype,e={},c=function(j,h){
for(var k in j)
{
if(h(j[k],k)===false)
{
break;
}
}
};
c(d,function(h,i){
var k=f[i],j=k||h;
e[i]=function(l){
var m=[].slice.call(arguments);
m.shift();
return j.apply(l,m);
};
});
var b=function(){
};
b.prototype=e;
var g=new b();
g.extendPrototype=function(h){
c(d,function(i,j){
if(!f[j])
{
f[j]=i;
}
});
};
g.ctor=function(){
return e;
};
a.ArrayEx=g;
})(window);
(function(){
var c={},e="_simple_event_obj_",d="_simple_event_handler_";
function b(f,g)
{
return f[g]||(f[g]={});
}
function a(f,g,h)
{
for(var k in f)
{
for(var l in g)
{
if(k==l&&k.indexOf(h)!=-1)
{
return l;
}
}
}
}
c.addEvent=function(h,i,f,g){
var j=b(h,e),k=b(f,d),l=a(j,k,i);
if(!l)
{
l=[Math.random(),i].join(",");
}
j[l]=[f,g||{}];
k[l]=1;
};
c.delEvent=function(g,h,f){
var i=b(g,e),j=b(f,d),k=a(i,j,h);
if(k)
{
delete i[k];
delete j[k];
}
};
c.fireEvent=function(g,h,f){
var k=b(g,e);
for(var m in k)
{
if(new RegExp(","+h+"$").test(m))
{
var j=k[m];
try{
j[0].apply(j[1].oContext,f);
}
catch(l)
{
debug("fireEvent error @js/com/extend/simple_event.js:"+l.message);
}
}
}
};
window.QMSimpleEvent=c;
})();
var QMModelAdaptor=(function(){
return ({addEvent:QMSimpleEvent.addEvent,delEvent:QMSimpleEvent.delEvent,fireEvent:QMSimpleEvent.fireEvent,htmlEncode:getTop().htmlEncode,getValue:function(a,b){
if(!(a&&a[b]))
{
return null;
}
return typeof (a[b])=="function"?a[b]():a[b];
},each:getTop().E,toArr:function(a){
return [].slice.call(a);
},unikey:getTop().unikey,isArr:getTop().isArr,isStr:function(a){
return typeof a=="string";
},isFunc:function(a){
return typeof a=="function";
},isObj:function(a){
return typeof a=="object";
},extend:getTop().extend});
})();
(function(a){
var i=ArrayEx;
var m=[].splice;
var c=function(r){
if(!a.isObj(r))
{
return r;
}
return a.isArr(r)?r.slice():a.extend({},r);
};
var e=function(){
return a.unikey("c");
};
var o=({}).toString;
function n(r,s,y)
{
if(r===s)
{
return r!==0||1/r==1/s;
}
if(r==null||s==null)
{
return r===s;
}
if(r.isEqual&&a.isFunc(r.isEqual))
{
return r.isEqual(s);
}
if(s.isEqual&&a.isFunc(s.isEqual))
{
return s.isEqual(r);
}
var t=o.call(r);
if(t!=o.call(s))
{
return false;
}
switch(t)
{case '[object String]':
return r==String(s);
case '[object Number]':
return r!=+r?s!=+s:(r==0?1/r==1/s:r==+s);
case '[object Date]':
case '[object Boolean]':
return +r==+s;
case '[object RegExp]':
return r.source==s.source&&r.global==s.global&&r.multiline==s.multiline&&r.ignoreCase==s.ignoreCase;
}if(typeof r!='object'||typeof s!='object')
{
return false;
}
var v=y.length;
while(v--)
{
if(y[v]==r)
{
return true;
}
}
y.push(r);
var x=0,w=true;
if(t=='[object Array]')
{
x=r.length;
w=x==s.length;
if(w)
{
while(x--)
{
if(!(w=x in r==x in s&&n(r[x],s[x],y)))
break;
}
}
}
else{
if('constructor' in r!='constructor' in s||r.constructor!=s.constructor)
{
return false;
}
for(var u in r)
{
if(f(r,u))
{
x++;
if(!(w=f(s,u)&&n(r[u],s[u],y)))
break;
}
}
if(w)
{
for(u in s)
{
if(f(s,u)&&!(x--))
break;
}
w=!x;
}
}
y.pop();
return w;
}
var h=function(r,s){
return n(r,s,[]);
};
var f=function(s,r){
return Object.prototype.hasOwnProperty.call(s,r);
};
var b=function(r,s){
return function(){
return r.apply(s,arguments);
};
};
var g=function(s){
if(s==null)
{
return true;
}
if(a.isArr(s)||a.isStr(s))
{
return s.length===0;
}
for(var r in s)
if(f(s,r))
{
return false;
}
return true;
};
var p=function(){
throw new Error('A "url" property or function must be specified');
};
var q=function(r,s){
var t=a.toArr(arguments),u=t[1];
return function(){
var v=t.slice(1).concat(a.toArr(arguments));
if(r)
{
r.apply(v[1],v);
}
else{
s.fire.apply(s,["error"].concat(v));
}
};
};
var d=function(s,r){
var t=function(u){
if(u)
{
this.init_(u);
}
};
t.prototype=a.extend(new s(),r(s.prototype));
t.prototype.constructor=t;
return t;
};
var k=d(Object,function(r){
return ({on:function(){
var s=a.toArr(arguments);
s.unshift(this);
a.addEvent.apply(null,s);
},off:function(){
var s=a.toArr(arguments);
s.unshift(this);
a.delEvent.apply(null,s);
},fire:function(){
var t=this,s=a.toArr(arguments);
a.fireEvent(t,s[0],s.slice(1));
a.fireEvent(t,"all",s);
}});
});
var l=d(k,function(r){
return ({init_:function(s){
s=s||{};
var t=s.attributes;
var v=s.options;
var u;
t||(t={});
if(v&&v.parse)
t=this.parse(t);
if(u=a.getValue(this,'defaults'))
{
t=a.extend({},u,t);
}
if(v&&v.collection)
this.collection=v.collection;
this.attributes={};
this._escapedAttributes={};
this.cid=e('c');
if(!this.set(t,{silent:true}))
{
throw new Error("Can't create an invalid model");
}
delete this._changed;
this._previousAttributes=c(this.attributes);
this.initialize.apply(this,arguments);
},idAttribute:function(){
return "id";
},sync:function(){
},initialize:function(){
},toJSON:function(){
return c(this.attributes);
},get:function(s){
return this.attributes[s];
},escape:function(s){
var t;
if(t=this._escapedAttributes[s])
{
return t;
}
var u=this.attributes[s];
return this._escapedAttributes[s]=a.htmlEncode(u==null?'':''+u);
},has:function(s){
return this.attributes[s]!=null;
},set:function(w,B,y){
var u,t,A;
if(a.isObj(w)||w==null)
{
u=w;
y=B;
}
else{
u={};
u[w]=B;
}
y||(y={});
if(!u)
{
return this;
}
if(u instanceof l)
u=u.attributes;
if(y.unset)
for(t in u)
u[t]=void 0;
if(!this._validate(u,y))
{
return false;
}
if(this.idAttribute() in u)
this.id=u[this.idAttribute()];
var x=this.attributes;
var v=this._escapedAttributes;
var z=this._previousAttributes||{};
var s=this._setting;
this._changed||(this._changed={});
this._setting=true;
for(t in u)
{
A=u[t];
if(!h(x[t],A))
delete v[t];
y.unset?delete x[t]:x[t]=A;
if(this._changing&&h(this._changed[t],A))
{
this.fire('change:'+t,this,A,y);
this._moreChanges=true;
}
delete this._changed[t];
if(!h(z[t],A)||(f(x,t)!=f(z,t)))
{
this._changed[t]=A;
}
}
if(!s)
{
if(!y.silent&&this.hasChanged())
this.change(y);
this._setting=false;
}
return this;
},unset:function(s,t){
(t||(t={})).unset=true;
return this.set(s,null,t);
},clear:function(s){
(s||(s={})).unset=true;
return this.set(c(this.attributes),s);
},fetch:function(t){
t=t?c(t):{};
var s=this;
var u=t.onsuccess;
t.onsuccess=function(v,w,x){
if(!s.set(s.parse(v,x),t))
{
return false;
}
if(u)
u(s,v);
};
t.onerror=q(t.onerror,s,t);
return this.sync.call(this,'read',this,t);
},save:function(u,A,x){
var s,t;
if(a.isObj(u)||u==null)
{
s=u;
x=A;
}
else{
s={};
s[u]=A;
}
x=x?c(x):{};
if(x.wait)
t=c(this.attributes);
var y=a.extend({},x,{silent:true});
if(s&&!this.set(s,x.wait?y:x))
{
return false;
}
var w=this;
var z=x.onsuccess;
x.onsuccess=function(C,E,F){
var D=w.parse(C,F);
if(x.wait)
D=a.extend(s||{},D);
if(!w.set(D,x))
{
return false;
}
if(z)
{
z(w,C);
}
else{
w.fire('sync',w,C,x);
}
};
x.onerror=q(x.onerror,w,x);
var v=this.isNew()?'create':'update';
var B=this.sync.call(this,v,this,x);
if(x.wait)
this.set(t,y);
return B;
},destroy:function(t){
t=t?c(t):{};
var s=this;
var u=t.onsuccess;
var v=function(){
s.fire('destroy',s,s.collection,t);
};
if(this.isNew())
{
return v();
}
t.onsuccess=function(x){
if(t.wait)
v();
if(u)
{
u(s,x);
}
else{
s.fire('sync',s,x,t);
}
};
t.onerror=q(t.onerror,s,t);
var w=this.sync.call(this,'delete',this,t);
if(!t.wait)
v();
return w;
},url:function(){
var s=a.getValue(this.collection,'url')||a.getValue(this,'urlRoot')||p();
if(this.isNew())
{
return s;
}
return s+(s.charAt(s.length-1)=='/'?'':'/')+encodeURIComponent(this.id);
},parse:function(s,t){
return s;
},clone:function(){
return new this.constructor({attributes:this.attributes});
},isNew:function(){
return this.id==null;
},change:function(t){
if(this._changing||!this.hasChanged())
{
return this;
}
this._changing=true;
this._moreChanges=true;
for(var s in this._changed)
{
this.fire('change:'+s,this,this._changed[s],t);
}
while(this._moreChanges)
{
this._moreChanges=false;
this.fire('change',this,t);
}
this._previousAttributes=c(this.attributes);
delete this._changed;
this._changing=false;
return this;
},hasChanged:function(s){
if(!arguments.length)
{
return !g(this._changed);
}
return this._changed&&f(this._changed,s);
},changedAttributes:function(u){
if(!u)
{
return this.hasChanged()?c(this._changed):false;
}
var w,t=false,v=this._previousAttributes;
for(var s in u)
{
if(h(v[s],(w=u[s])))
continue;
(t||(t={}))[s]=w;
}
return t;
},previous:function(s){
if(!arguments.length||!this._previousAttributes)
{
return null;
}
return this._previousAttributes[s];
},previousAttributes:function(){
return c(this._previousAttributes);
},isValid:function(){
return !this.validate(this.attributes);
},_validate:function(s,u){
if(u.silent||!this.validate)
{
return true;
}
s=a.extend({},this.attributes,s);
var t=this.validate(s,u);
if(!t)
{
return true;
}
if(u&&u.onerror)
{
u.onerror(this,t,u);
}
else{
this.fire('error',this,t,u);
}
return false;
}});
});
var j=d(k,function(){
var r={init_:function(s){
s=s||{};
var t=s.models;
var u=s.options;
u||(u={});
if(u.comparator)
this.comparator=u.comparator;
this._reset();
this.initialize.apply(this,arguments);
if(t)
{
this.reset(t,{silent:true,parse:u.parse});
}
},initialize:function(){
},sync:function(){
},model:l,initialize:function(){
},toJSON:function(){
return this.map(function(s){
return s.toJSON();
});
},add:function(A,B){
var u,x,y,z,s,v,t={},w={};
B||(B={});
A=a.isArr(A)?A.slice():[A];
for(u=0,y=A.length;u<y;u++)
{
if(!(z=A[u]=this._prepareModel(A[u],B)))
{
throw new Error("Can't add an invalid model to a collection");
}
if(t[s=z.cid]||this._byCid[s]||(((v=z.id)!=null)&&(w[v]||this._byId[v])))
{
throw new Error("Can't add the same model to a collection twice");
}
t[s]=w[v]=z;
}
for(u=0;u<y;u++)
{
(z=A[u]).on("all",this._onModelEvent,{oContext:this});
this._byCid[z.cid]=z;
if(z.id!=null)
this._byId[z.id]=z;
}
this.length+=y;
x=B.at!=null?B.at:this.models.length;
m.apply(this.models,[x,0].concat(A));
if(this.comparator)
{
this.sort({silent:true});
}
if(B.silent)
{
return this;
}
for(u=0,y=this.models.length;u<y;u++)
{
if(!t[(z=this.models[u]).cid])
continue;
B.index=u;
z.fire('add',z,this,B);
}
this.fire('adds',A,this,B);
return this;
},remove:function(w,x){
var s,u,t,v;
x||(x={});
w=a.isArr(w)?w.slice():[w];
for(s=0,u=w.length;s<u;s++)
{
v=this.getByCid(w[s])||this.get(w[s]);
if(!v)
continue;
delete this._byId[v.id];
delete this._byCid[v.cid];
t=this.indexOf(v);
this.models.splice(t,1);
this.length--;
if(!x.silent)
{
x.index=t;
v.fire('remove',v,this,x);
}
this._removeReference(v);
}
this.fire('removes',w,this,x);
return this;
},get:function(s){
if(s==null)
{
return null;
}
return this._byId[s.id!=null?s.id:s];
},getByCid:function(s){
return s&&this._byCid[s.cid||s];
},at:function(s){
return this.models[s];
},sort:function(t){
t||(t={});
if(!this.comparator)
throw new Error('Cannot sort a set without a comparator');
var s=b(this.comparator,this);
if(this.comparator.length==1)
{
this.models=this.sortBy(s);
}
else{
this.models.sort(s);
}
if(!t.silent)
this.fire('reset',this,t);
return this;
},pluck:function(s){
return i.map(this.models,function(t){
return t.get(s);
});
},reset:function(u,v){
u||(u=[]);
v||(v={});
for(var s=0,t=this.models.length;s<t;s++)
{
this._removeReference(this.models[s]);
}
this._reset();
this.add(u,{silent:true,parse:v.parse});
if(!v.silent)
this.fire('reset',this,v);
return this;
},fetch:function(t){
t=t?c(t):{};
if(t.parse===undefined)
t.parse=true;
var s=this;
var u=t.onsuccess;
t.onsuccess=function(v,w,x){
s[t.add?'add':'reset'](s.parse(v,x),t);
if(u)
u(s,v);
};
t.onerror=q(t.onerror,s,t);
return this.sync.call(this,'read',this,t);
},create:function(t,u){
var s=this;
u=u?c(u):{};
t=this._prepareModel(t,u);
if(!t)
{
return false;
}
if(!u.wait)
s.add(t,u);
var v=u.onsuccess;
u.onsuccess=function(w,x,y){
if(u.wait)
s.add(w,u);
if(v)
{
v(w,x);
}
else{
w.fire('sync',t,x,u);
}
};
t.save(null,u);
return t;
},parse:function(s,t){
return s;
},_reset:function(s){
this.length=0;
this.models=[];
this._byId={};
this._byCid={};
},_prepareModel:function(t,u){
if(!(t instanceof l))
{
var s=t;
u.collection=this;
t=new this.model({attributes:s,options:u});
if(!t._validate(t.attributes,u))
t=false;
}
else if(!t.collection)
{
t.collection=this;
}
return t;
},_removeReference:function(s){
if(this==s.collection)
{
delete s.collection;
}
s.off("all",this._onModelEvent);
},_onModelEvent:function(t,u,s,v){
if((t=='add'||t=='remove')&&s!=this)
{
return;
}
if(t=='destroy')
{
this.remove(u,v);
}
if(u&&t==='change:'+u.idAttribute())
{
delete this._byId[u.previous(u.idAttribute())];
this._byId[u.id]=u;
}
this.fire.apply(this,arguments);
}};
a.each(i.ctor(),function(s,t){
r[t]=function(){
return s.apply(s,[this.models].concat(a.toArr(arguments)));
};
});
return r;
});
window.QMCommModel={inherit:d,qmModel:l,qmCollection:j};
})(QMModelAdaptor);
var QMFtnAdaptor=(function(){
var b={"5_img":"image","4_doc":"txt,html,word,ppt,excel,eml,pdf","3_video":"video","2_music":"audio","1_compress":"compress","0_default":"default"};
for(var d in b)
{
var a=b[d].split(",");
for(var e=a.length-1;e>=0;e--)
{
a[e]&&(b[a[e]]=d);
}
}
var c=getTop();
return ({S:S,waitFor:c.waitFor,getUin:c.getUin,ossLog:c.ossLog,gnIEVer:c.gnIEVer,gbIsOpera:c.gbIsOpera,gbIsIE:c.gbIsIE,gbIsFF:c.gbIsFF,gbIsChrome:c.gbIsChrome,gbIsSafari:c.gbIsSafari,isArr:c.isArr,extend:c.extend,QMAjax:c.QMAjax,getSid:c.getSid,T:c.T,TE:c.TE,evalValue:c.evalValue,getFileGroup:function(f){
return b[c.getFileTypeByExt(f.split(".").pop())]||"0_default";
},getFileType:function(f){
return c.getFileTypeByExt(f.split(".").pop());
},getViewType:function(f){
return c.getViewTypeByExt(f.split(".").pop());
},getFileIcon:function(f){
return c.getIconByExt(f.split(".").pop());
}});
})();
(function(_aoWin,A){
if(_aoWin.QMFtnModels&&_aoWin.QMFtnModels.oModels)
{
return;
}
var _oArrLib=ArrayEx,_fInherit=QMCommModel.inherit,_oFiles,_oUpFiles,_oUserInfo,_oFavFiles,_oFavDirs;
var _fWrapOnload=function(_aoModel,_aoOptions){
return function(_abOK,_asParam){
if(_abOK)
{
var _oData=A.evalValue(_asParam||"{}")||{};
if(_abOK&&_oData.errcode=="0")
{
}
else{
_aoModel.fire("error",_oSelf,_oData);
}
}
};
};
var _suffix=function(_asName){
var _oName=/.*\.(.*?)$/.exec(_asName);
return _oName?_oName[1].toLowerCase():"";
};
var _oModelEx=_fInherit(QMCommModel.qmModel,function(){
return ({toTmplJSON:function(){
return A.extend({cid:this.cid},this.toJSON());
}});
});
var _oCollEx=_fInherit(QMCommModel.qmCollection,function(_aoSuper){
return ({add:function(_aoModels,_aoOptions){
var _oSelf=this;
if(_aoOptions&&_aoOptions.checkDup)
{
var _oBuf=[];
_oArrLib.forEach(_aoModels,function(_aoItem){
var _oModel=_oSelf.get(_aoItem.sFileId);
if(_oModel)
{
_oModel.set(_aoItem,_aoOptions);
}
else{
_oBuf.push(_aoItem);
}
});
_aoModels=_oBuf;
}
return _aoSuper.add.apply(_oSelf,[_aoModels,_aoOptions]);
},update:function(_aoDatas){
var _oSelf=this,_oModel=_oSelf.at(0),_oIdx={},_sIdAttr,_oDels,_oAdds;
if(!_oModel)
{
return _oSelf.add(_aoDatas);
}
_sIdAttr=_oModel.idAttribute();
ArrayEx.forEach(_aoDatas,function(_aoItem){
var _oModel=_oSelf.get(_aoItem[_sIdAttr]);
_oIdx[_aoItem[_sIdAttr]]=_aoItem;
if(_oModel)
{
_oModel.set(_aoItem);
}
});
_oDels=_oSelf.filter(function(_aoModel){
return !_oIdx[_aoModel.get(_sIdAttr)];
});
_oAdds=ArrayEx.filter(_aoDatas,function(_aoItem){
return !_oSelf.get(_aoItem[_sIdAttr]);
});
_oDels&&_oDels.length&&_oSelf.remove(_oDels);
_oAdds&&_oAdds.length&&_oSelf.add(_oAdds);
return _oSelf;
},removeFile:function(_asIds,_aoOptions,_abSelectAll,_asKeyText){
var _oSelf=this,_oFids=[],_oModels=[],_asIds=A.isArr(_asIds)?_asIds:[_asIds];
_aoOptions=_aoOptions||{};
var _oNextModels=[];
ArrayEx.forEach(_asIds,function(_asId){
var _oModel=_oSelf.getByCid(_asId)||_oSelf.get(_asId),_sFid=_oModel&&_oModel.get("sFileId");
if(_oModel)
{
_sFid&&_oFids.push(_sFid);
if(_oModel.cancel)
{
_oModel.cancel();
if(!_aoOptions.bPreventNext)
{
_oNextModels.push(_oModel);
}
}
_oModels.push(_oModel);
}
});
if(_oModels.length)
{
_oSelf.remove(_oModels);
_oSelf.updateUsedSpace&&_oSelf.updateUsedSpace(_oModels,-1);
_oSelf.updateTotal&&_oSelf.updateTotal(_oModels,-_oModels.length);
}
if(_oNextModels.length)
{
ArrayEx.forEach(_oNextModels,function(_aoModel){
_oUpFiles.next(_aoModel);
});
}
if(_oFids.length&&!_aoOptions.bNotSync)
{
A.QMAjax.send(A.TE(["/cgi-bin/ftnDelFile?sid=$sid$&t=ftn.json&s=$oper$&ef=js&pathid=$pathid$&keytext=$keytext$"]).replace({keytext:_asKeyText||"",oper:_abSelectAll?"delall":"oper",pathid:_aoOptions.sPathId||"",sid:A.getSid()}),{content:_abSelectAll?"":A.TE(["$@$for($fids$)$@$","&fid=$_this_$","$@$endfor$@$"]).replace({fids:_oFids}),method:"POST",timeout:5*60*1000,onload:function(_abOK,_asParam){
if(_abOK)
{
var _oData=A.evalValue(_asParam||"{}")||{};
if(_abOK&&_oData.errcode=="0")
{
_oIndexs.drop(new RegExp(_aoOptions.sListType+".*"));
_aoOptions.onsuccess&&_aoOptions.onsuccess();
}
else{
_oIndexs.dirty(new RegExp(_aoOptions.sListType+".*"));
_aoOptions.onerror&&_aoOptions.onerror();
}
}
else{
_oIndexs.dirty(new RegExp(_aoOptions.sListType+".*"));
_aoOptions.onerror&&_aoOptions.onerror();
}
_aoOptions.oncomplete&&_aoOptions.oncomplete();
}});
}
else{
_aoOptions.onsuccess&&_aoOptions.onsuccess();
_aoOptions.oncomplete&&_aoOptions.oncomplete();
}
},model:_oModelEx,toTmplJSON:function(_aoModels){
return _oArrLib.map(_aoModels||this.models,function(_aoModel){
return _aoModel.toTmplJSON();
});
}});
});
var _INFI_LENGTH=500;
var _PAGE_SIZE=A.gnIEVer&&(A.gnIEVer<8)?20:50;
if(getTop().getUin()=="994919736"||getTop().getUin()=="1460116134")
{
_PAGE_SIZE=10;
}
var _PAGE_COUNT=2;
var _qmFtnFile=_fInherit(_oModelEx,function(){
return ({idAttribute:function(){
return "sFileId";
}});
});
var _qmFtnFiles=_fInherit(_oCollEx,function(_aoSuper){
return ({init_:function(_aoCfg){
_aoSuper.init_.apply(this,arguments);
},updateUsedSpace:function(_aoModels,_anOper){
_updateUsedSpace("",_aoModels,_anOper);
},updateTotal:function(_aoModels,_anOper){
_updateTotal(_anOper);
},model:_qmFtnFile,parse:function(_aoResponse){
var _oReFiles=[],_oStoppeds=[];
_oUserInfo.set(_aoResponse.oUserInfo);
if(_aoResponse.oDirs)
{
_aoResponse.oDirs.length&&_oFavDirs.add(_aoResponse.oDirs,{checkDup:true,silent:true});
}
ArrayEx.forEach(_aoResponse.oFiles,function(_aoFile){
if(!_aoFile)
{
return;
}
var _oModel=_oUpFiles.getByFid(_aoFile.sFileId);
if(_oModel)
{
if(_oModel.get("sStatus")=="stopped")
{
_oModel.set(_aoFile);
}
}
else{
if(_aoFile.sStatus=="stopped")
{
_aoFile.sFrom="list";
_oStoppeds.push(_aoFile);
}
else{
_oReFiles.push(_aoFile);
}
}
_aoFile.sColl=({stopped:"UpFiles",complete:"Files"})[_aoFile.sStatus];
});
_oStoppeds.length&&_oUpFiles.add(_oStoppeds,{checkDup:true,silent:true});
return _oReFiles;
},url:function(){
return "/FtnRes/Files/";
},addDownCnt:function(_asCid){
var _oSelf=this,_oFile=_oSelf.getByCid(_asCid),_nCount=_oFile.get("nDownCnt");
_oFile.set("nDownCnt",_nCount);
_oIndexs.dirty(/,downloadcnt/);
return _nCount;
},addFav:function(_aoCids,_aoOptions){
var _oSelf=this,_sFid,_oModels=[],_nFavFullSize=_oUserInfo.get("nFavFullSpace"),_nFavUsedSize=_oUserInfo.get("nFavUsedSpace"),_oFids=[];
if(ArrayEx.some(_aoCids,function(_asCid){
var _oModel=_oSelf.getByCid(_asCid);
if(!_oModel)
{
return true;
}
_nFavUsedSize+=(_oModel.get("nSize")/1024/1024);
if(_nFavFullSize<_nFavUsedSize)
{
return true;
}
_oModels.push(_oModel);
_oFids.push(_oModel.get("sFileId"));
}))
{
_aoOptions.onerror&&_aoOptions.onerror(-1,"size,-1,addFav");
}
A.QMAjax.send(A.TE(["/cgi-bin/ftnFavorite?sid=$sid$&topathid=$pathid$&oper=add&t=ftn.json&s=addfav&ef=js&loc=ftnFavorite,ftn.json,addFav,0"]).replace({sid:A.getSid(),pathid:"/"}),{content:ArrayEx.map(_oFids,function(_asFid){
return "fid="+_asFid;
}).join("&"),method:"POST",onload:function(_abOK,_asParam){
var _oData=A.evalValue(_asParam||"{}")||{};
if(_abOK)
{
if(_abOK&&_oData.errcode=="0")
{
_oIndexs.dirty(/favorite,\//);
_oSelf.updateUsedSpace&&_oSelf.updateUsedSpace(_oModels,-1);
ArrayEx.forEach(_oModels,function(_aoModel){
_aoModel.destroy();
});
_aoOptions.onsuccess&&_aoOptions.onsuccess();
}
else{
_aoOptions.onerror&&_aoOptions.onerror(_oData.errcode,["cgi",_oData.errcode,"ftnFavorite"].join(","));
}
}
else{
_aoOptions.onerror&&_aoOptions.onerror(_oData.errcode,["cgi",_oData.errcode,"ftnFavorite"].join(","));
}
}});
getTop().ossLog("delay","all","stat=nothing&loc=ftnExs_files,ftn,ftntofav,0");
},renameFile:function(_asId,_asNewName){
var _oSelf=this,_oModel=_oSelf.getByCid(_asId),_sFid=_oModel.get("sFileId");
_oModel.set("sName",_asNewName);
A.QMAjax.send(A.TE(["/cgi-bin/ftnTagMgr?sid=$sid$&t=ftn.json&fid=$fid$&filename=$filename$&s=oper&ef=js&resp_charset=UTF8&oper=filealter&bus=$bus$"]).replace({sid:A.getSid(),filename:encodeURIComponent(_asNewName),bus:_oModel.get("nAppId"),fid:_sFid}),{method:"POST",onload:function(_abOK,_asParam){
if(_abOK)
{
var _oData=A.evalValue(_asParam||"{}")||{};
if(_abOK&&_oData.errcode=="0")
{
}
else{
_aoModel.fire("error",_oSelf,_oData);
}
}
}});
},renewFile:function(_asIds,_aoOptions,_abSelectAll,_asKeyText){
var _oSelf=this,_asIds=A.isArr(_asIds)?_asIds:[_asIds];
A.QMAjax.send(A.TE(["/cgi-bin/ftnExtendfile?sid=$sid$&t=ftn.json&s=$oper$&ef=js&keytext=$keytext$"]).replace({keytext:_asKeyText||"",oper:_abSelectAll?"extendall":"oper",sid:A.getSid()}),{content:_abSelectAll?"":A.TE(["$@$for($fids$)$@$","&fid=$_this_$","$@$endfor$@$"]).replace({fids:ArrayEx.map(_asIds,function(_asId){
var _oModel=_oSelf.getByCid(_asId)||_oSelf.get(_asId);
return _oModel&&_oModel.get("sFileId");
})}),timeout:2*60*1000,method:"POST",onload:function(_abOK,_asParam){
if(_abOK)
{
var _oData=A.evalValue(_asParam||"{}")||{};
if(_abOK&&_oData.errcode=="0")
{
ArrayEx.forEach(_asIds,function(_asId){
var _oModel=_oSelf.getByCid(_asId)||_oSelf.get(_asId);
if(_oModel)
{
_oModel.set("nExpireTime",_oUserInfo.get("nExpireDays")*24*60*60-1);
}
});
if(_abSelectAll)
{
_oIndexs.dirty(/self.*/);
}
else{
_oIndexs.dirty(/self,,time/);
}
_aoOptions&&_aoOptions.onsuccess();
}
else{
_aoOptions&&_aoOptions.onerror(_oData);
}
}
else{
_aoOptions&&_aoOptions.onerror(_oData);
}
}});
}});
});
var _qmFavDir=_fInherit(_qmFtnFile,function(_aoSuper){
return ({parse:function(_aoResponse){
return _aoResponse.oDir;
},sync:function(_asMethod,_aoModel,_aoOptions){
var _oSelf=this;
if(_asMethod=="create")
{
A.QMAjax.send(A.T("/cgi-bin/ftnFavorite?sid=$sid$&oper=create&pathid=$pathid$&pathname=$pathname$&t=ftn.json&s=createdir&ef=js&resp_charset=UTF8").replace({sid:A.getSid(),pathid:"",pathname:encodeURIComponent(_aoModel.get("sName"))}),{method:"GET",onload:function(_abOK,_asParam){
var _oData=A.evalValue(_asParam||"{}")||{};
if(_abOK)
{
if(_abOK&&_oData.errcode=="0")
{
_aoOptions.onsuccess&&_aoOptions.onsuccess(_oData);
}
else{
_aoOptions.onerror&&_aoOptions.onerror(_oData);
}
}
else{
_aoOptions.onerror&&_aoOptions.onerror(_oData);
}
}});
}
}});
});
var _qmFavDirs=_fInherit(_oCollEx,function(_aoSuper){
return ({model:_qmFavDir,url:function(){
return "/FtnRes/FavDirs/";
},addDir:function(_asName,_aoOptions){
var _oSelf=this;
_aoOptions=_aoOptions||{};
_aoOptions.wait=true;
if(_asName)
{
_oSelf.create({sName:_asName,sPathId:"/"},_aoOptions);
}
},renameFile:function(_asId,_asNewName){
var _oSelf=this,_oModel=_oSelf.getByCid(_asId)||_oSelf.get(_asId),_sOldName=_oModel.get("sName");
if(_oModel&&_asNewName)
{
var _sFid=_oModel.get("sFileId");
A.QMAjax.send(A.T("/cgi-bin/ftnFavorite?sid=$sid$&oper=rename&pathid=$pathid$&pathname=$name$&t=ftn.json&s=oper&ef=js&resp_charset=UTF8").replace({sid:A.getSid(),pathid:_sFid,name:encodeURIComponent(_asNewName)}),{method:"GET",onload:function(_abOK,_asParam){
var _oData=A.evalValue(_asParam||"{}")||{};
if(_abOK)
{
if(_abOK&&_oData.errcode=="0")
{
}
else{
_oModel.set("sName",_sOldName);
_oSelf.fire("error",_oModel,_oData);
}
}
else{
}
}});
_oModel.set("sName",_asNewName);
}
},removeDir:function(_asId){
var _oSelf=this,_oModel=_oSelf.getByCid(_asId)||_oSelf.get(_asId);
if(_oModel)
{
var _sFid=_oModel.get("sFileId");
A.QMAjax.send(A.T("/cgi-bin/ftnFavorite?sid=$sid$&oper=del&pathid=$pathid$&t=ftn.json&s=oper&ef=js").replace({sid:A.getSid(),pathid:_sFid}),{method:"GET",onload:_fWrapOnload(_oSelf)});
var _oUpModels=_oUpFiles.filter(function(_aoItem){
return _aoItem.get("sPathId")==_sFid;
});
ArrayEx.forEach(_oUpModels,function(_aoItem){
_aoItem.cancel();
});
_oModel.destroy();
_oIndexs.dirty(/favorite,\//);
}
}});
});
var _qmFavFile=_fInherit(_qmFtnFile,function(_aoSuper){
return ({});
});
var _qmFavFiles=_fInherit(_qmFtnFiles,function(_aoSuper){
return ({model:_qmFavFile,url:function(){
return "/FtnRes/FavFiles/";
},setPathId:function(_asPathId,_asIds,_aoOptions){
var _oSelf=this,_sFromPathId,_asIds=A.isArr(_asIds)?_asIds:[_asIds],_oRemoves=[],_oFids=[];
_aoOptions=_aoOptions||{};
ArrayEx.forEach(_asIds,function(_asId){
_oModel=_oSelf.getByCid(_asId);
if(_oModel)
{
_oFids.push(_oModel.get("sFileId"));
_sFromPathId=_oModel.get("sPathId");
_oRemoves.push(_oModel);
}
});
A.QMAjax.send(A.T("/cgi-bin/ftnFavorite?sid=$sid$&t=ftn.json&s=oper&ef=js&oper=move&frompathid=$from$&topathid=$to$").replace({from:_sFromPathId,to:_asPathId,sid:A.getSid()}),{content:ArrayEx.map(_oFids,function(_asFid){
return "fid="+_asFid;
}).join("&"),method:"POST",onload:function(_abOK,_asParam){
var _oData=A.evalValue(_asParam||"{}")||{};
if(_abOK)
{
if(_abOK&&_oData.errcode=="0")
{
_oSelf.remove(_oRemoves);
_oIndexs.dirty(new RegExp("favorite,"+_asPathId));
_oIndexs.dirty(new RegExp("favorite,/"));
_aoOptions.onsuccess&&_aoOptions.onsuccess();
}
else{
_aoOptions.onerror&&_aoOptions.onerror(_oData.errcode,_oData.errmsg);
}
}
else{
_aoOptions.onerror&&_aoOptions.onerror(_oData.errcode,_oData.errmsg);
}
}});
},updateUsedSpace:function(_aoModels,_anOper){
_updateUsedSpace("Fav",_aoModels,_anOper);
},password:function(_asPassWord,_aoOptions){
if(!_asPassWord)
{
return;
}
A.QMAjax.send(A.T("/cgi-bin/ftnNDPwd?sid=$sid$&web=&ndcmd=CheckPwd&t=ftn.json&s=pwd&pwd=$pwd$&ef=js").replace({pwd:encodeURIComponent(_asPassWord),sid:A.getSid()}),{method:"POST",onload:function(_abOK,_asParam){
var _oData=A.evalValue(_asParam||"{}")||{};
if(_abOK&&_oData.errcode=="0")
{
_aoOptions.onsuccess(_oData);
}
else{
_aoOptions.onerror&&_aoOptions.onerror(_oData.errcode,_oData.errmsg);
}
}});
},sync:function(_asMethod,_aoModel,_aoOptions){
if(_asMethod=="read")
{
var _oSelf=this;
A.QMAjax.send(A.T("/cgi-bin/ftnExs_files?sid=$sid$&t=ftn.json&s=list&pwpage=false&listtype=favorite&pathid=$pathid$&fileid=$fileid$&count=$count$&ef=js&up=$order$&sorttype=$sorttype$").replace({pathid:_aoOptions.sPathId||"/",count:_aoOptions.nCount,sid:A.getSid(),order:_oSelf._moOrder.nOrder==-1?"down":"up",sorttype:_oSortMap[_oSelf._moOrder.sSortType],fileid:_aoOptions.sFileId}),{method:"GET",headers:{"If-Modified-Since":"0","Cache-Control":"no-cache, max-age=0"},onload:function(_abOK,_asParam){
var _oData=A.evalValue(_asParam||"{}")||{};
if(_abOK&&_oData.errcode=="0")
{
_aoOptions.onsuccess(_oData);
}
else{
_aoOptions.onerror&&_aoOptions.onerror(_oData.errcode,_oData.errmsg);
}
}});
}
}});
});
var _qmFtnUserInfo=_fInherit(_oModelEx,function(_aoSuper){
return ({expireAlert:function(_abOpen){
var _oSelf=this;
_oSelf.save({bExpireAlert:_abOpen},{bAlert:true});
return _oSelf;
},sync:function(_asMethod,_aoModel,_aoOptions){
var _oSelf=this;
if(_asMethod=="update")
{
if(_aoOptions.bAlert)
{
A.QMAjax.send(A.T("/cgi-bin/setting7?sid=$sid$&t=ftn.json&s=oper&ef=js&fun=remind&set=$set$").replace({sid:A.getSid(),set:_oSelf.get("bExpireAlert")?1:0}),{method:"GET",onload:_fWrapOnload(_oSelf)});
}
}
else if(_asMethod=="read")
{
A.QMAjax.send(A.T("/cgi-bin/ftnfilefunc?sid=$sid$&oper=profile&t=ftn.json&s=userinfo&ef=js").replace({sid:A.getSid()}),{method:"GET",onload:function(_abOK,_asParam){
var _oData=A.evalValue(_asParam||"{}")||{};
if(_abOK&&_oData.errcode=="0")
{
_aoOptions&&_aoOptions.onsuccess&&_aoOptions.onsuccess(_oData);
}
else{
_aoOptions.onerror(_oData.errcode,_oData.errmsg);
}
}});
}
},parse:function(_aoResponse){
return _aoResponse.oUserInfo;
},toTmplJSON:function(){
return A.extend({cid:this.cid},this.toJSON());
},idAttribute:function(){
return "nUin";
},url:function(){
return "/FtnRes/UserInfo/";
}});
});
var _qmFtnUpFile=_fInherit(_oModelEx,function(_aoSuper){
function _getUpType(_sType)
{
if(/Rawinput/.test(_sType))
{
return 1;
}
else if(/Flash/.test(_sType))
{
return 2;
}
else if(/Ftn/.test(_sType))
{
if(A.gbIsIE)
{
return 3;
}
else if(A.gbIsFF)
{
return 4;
}
else if(A.gbIsChrome)
{
return 5;
}
else if(A.gbIsSafari)
{
return 6;
}
else if(A.gbIsOpera)
{
return 7;
}
}
}
return ({init_:function(_aoCfg){
var _oSelf=this;
_oSelf._initFile(_aoCfg.options.oFile);
return _aoSuper.init_.call(_oSelf,_aoCfg);
},_initFile:function(_aoFile){
var _oSelf=this;
if(_aoFile)
{
_oSelf.oFile=_aoFile;
}
},cancel:function(){
var _oSelf=this;
_oSelf.oFile&&_oSelf.oFile.cancel();
},pause:function(){
var _oSelf=this;
if(_oSelf.oFile&&_oSelf.oFile.pause)
{
return _oSelf.oFile.pause();
}
else{
return false;
}
},uploadToFtn:function(){
var _oSelf=this;
if(_oSelf.oFile)
{
if(_oSelf.oFile.checkUpFileFrom&&!_oSelf.oFile.checkUpFileFrom())
{
var _sOrigStatus=_oSelf.get('sStatus');
_oSelf.set('sStatus','skipUpload');
setTimeout(function(){
_oSelf.set('sStatus',_sOrigStatus);
},0);
return false;
}
if(_oSelf.oFile.resumeLocal)
{
_oSelf.oFile.resumeLocal();
return true;
}
else if(_oSelf._checkUpFileSize())
{
_oSelf.oFile.uploadToFtn();
return true;
}
else{
return false;
}
}
},ossLog:function(){
var _oSelf=this;
A.ossLog("delay","all",A.T("stat=ftn_v2&log=getinvestigate,$uin$,$ret$,0,$usedtime$,0,0,0,$size$,0,0,0,$uptype$,$listtype$&ret=$ret$&err=$error$").replace({uin:A.getUin(),ret:_oSelf.get("sStatus")=="complete"?1:0,error:_oSelf.get("sError")||"",usedtime:_oSelf.get("nUsedTime"),size:_oSelf.get("nSize"),uptype:_getUpType(_oSelf.get("sType")),listtype:_oSelf.get("nAppId")=="5"?"favorite":"self"}));
},_checkUpFileSize:function(){
var _oSelf=this,_sType=_oSelf.get("sPathId")==""?"":"Fav",_nSize=_oSelf.get("nSize"),_nMaxSize=_oUserInfo.get("nMaxFileSize"),_sUsedSpace="n"+_sType+"UsedSpace",_sFullSpace="n"+_sType+"FullSpace";
if(typeof _nSize=="undefined")
{
return true;
}
if(_nSize<0)
{
_oSelf.set({"sStatus":"error","sError":"size,-5"});
return false;
}
if(_nSize>_nMaxSize)
{
_oSelf.set({"sStatus":"error","sError":"size,-1,"+_nMaxSize});
_oSelf.oFile.oUploader.ossLog(_oSelf);
return false;
}
if(_nSize==0)
{
_oSelf.set({"sStatus":"error","sError":"size,-2,0"});
return false;
}
if(_nSize/1024/1024+_oUserInfo.get(_sUsedSpace)>=_oUserInfo.get(_sFullSpace))
{
_oSelf.set({"sStatus":"error","sError":"size,-4,0"});
return false;
}
return true;
},retry:function(){
var _oSelf=this;
_oSelf.set("sStatus","ready");
_oUpFiles.next();
},resume:function(_aoUploader){
var _oSelf=this;
if(!_oSelf.oFile||!_oSelf.oFile.resumeLocal)
{
_oSelf.oFile=_aoUploader.resume(_oSelf.toJSON());
_oSelf.set(_oSelf.oFile.get());
}
else{
_oSelf.oFile.resumeLocal();
}
},idAttribute:function(){
return "sId";
},toTmplJSON:function(){
return A.extend({cid:this.cid},this.toJSON());
}});
});
var _qmFtnUpFiles=_fInherit(_oCollEx,function(_aoSuper){
return ({comparator:function(_aoModel1,_aoModel2){
var _nDiff=(_aoModel1.get("sFrom")=="list"?1:0)-(_aoModel2.get("sFrom")=="list"?1:0);
if(!_nDiff)
{
if(_aoModel1.get("nCreateTime")&&_aoModel2.get("nCreateTime"))
{
return _aoModel2.get("nCreateTime")-_aoModel1.get("nCreateTime");
}
}
return _nDiff;
},model:_qmFtnUpFile,getByFid:function(_asFid){
return this.filter(function(_aoItem){
return _aoItem.get("sFileId")==_asFid;
})[0];
},updateUsedSpace:function(_aoModels,_anOper){
var _oColl=_aoModels[0].get("nAppId")=="5"?_oFavFiles:_oFiles;
_oColl.updateUsedSpace(_aoModels,_anOper);
},updateTotal:function(_aoModels,_anOper){
_updateTotal(_anOper);
},toTmplJSON:function(_aoModels){
return _oArrLib.map(_aoModels||this.models,function(_aoModel){
return _aoModel.toTmplJSON();
});
},next:function(_aoModel){
var _oReadys=this.filter(function(_aoItem){
return (_aoItem.get("sStatus")=="ready");
});
if(_oReadys.length)
{
var _oFile=_oReadys[0];
getTop().increaseUploadCount(_oFile.oFile.oUploader.name);
if(!_oFile.uploadToFtn())
{
_oUpFiles.next(_oFile);
}
}
},getByAppId:function(){
var _oSelf=this;
return _oSelf.filter(function(_aoItem){
return _aoItem.get("nAppId")==_anAppId;
});
},isUploading:function(_anAppId){
var _oSelf=this;
return _oSelf.some(function(_aoModel){
return _aoModel.get("nAppId")==_anAppId&&/uploading|ready/.test(_aoModel.get("sStatus"));
});
},getByNotInSvr:function(_asPathId){
var _oSelf=this;
return _oSelf.filter(function(_aoItem){
return !_aoItem.get("sFileId")&&_aoItem.get("sPathId")==_asPathId;
});
},url:function(){
return "/FtnRes/UpFiles/";
}});
});
_oFiles=new _qmFtnFiles({});
_oFavFiles=new _qmFavFiles({});
_oFavDirs=new _qmFavDirs({});
_oUserInfo=new _qmFtnUserInfo({});
_oUpFiles=new _qmFtnUpFiles({});
function _updateUsedSpace(_asSpace,_aoModels,_anOper)
{
var _nUsedSpace=_oUserInfo.get("n"+_asSpace+"UsedSpace"),_nFullSpace=_oUserInfo.get("n"+_asSpace+"FullSpace");
ArrayEx.forEach(_aoModels,function(_aoModel){
if(typeof _aoModel.get("nSize")=="undefined"||!_aoModel.get("sFileId"))
{
return;
}
_nUsedSpace=_nUsedSpace+(_anOper*_aoModel.get("nSize")/1024/1024);
});
_oUserInfo.set("n"+_asSpace+"UsedSpace",Math.min(Math.max(+_nUsedSpace.toFixed(2),0),_nFullSpace));
}
function _updateTotal(_anOper)
{
var _nTotal=_oUserInfo.get("nTotalFile");
_oUserInfo.set("nTotalFile",_nTotal+_anOper);
}
_oUpFiles.on("change:sFileId",function(_aoModel){
var _oColl=_aoModel.get("nAppId")=="5"?_oFavFiles:_oFiles;
_oColl.updateUsedSpace([_aoModel],1);
});
var _qmFtnMgr={oCfg:{onselect:function(_aoFiles,_abAutoUploadAfterSelect){
if(!_aoFiles.length)
{
return;
}
if(_aoFiles.length>=40)
{
_oUpFiles.fire("error",null,"size,-3,0");
return;
}
_oUpFiles.add(ArrayEx.map(_aoFiles,function(_aoFile){
var _oFile=new _qmFtnUpFile({attributes:_aoFile.get(),options:{oFile:_aoFile}});
_oFile._checkUpFileSize();
return _oFile;
}));
if(_abAutoUploadAfterSelect!==false)
{
setTimeout(function(){
ArrayEx.forEach(_aoFiles,function(_aoFile){
_oUpFiles.next(_aoFile);
});
},0);
}
},onprocess:function(_aoFile){
var _oUpFile=_oUpFiles.get(_aoFile.get("sId"));
_oUpFile&&_oUpFile.set(_aoFile.get());
},oncomplete:function(_aoFile){
var _oModel=_oUpFiles.get(_aoFile.get("sId"));
if(!_oModel)
{
return;
}
_oModel=_oModel.set(_aoFile.get());
if(_oModel.get("nAppId")==2)
{
_oModel.set("nExpireTime",_oUserInfo.get("nExpireDays")*24*60*60-1);
}
var _oColl=_oModel.get("nAppId")=="5"?_oFavFiles:_oFiles;
_oUpFiles.remove(_oModel);
_oColl.add(_oModel.toJSON());
_oModel.ossLog();
_oUpFiles.next(_oModel);
},onerror:function(_aoFile){
var _oModel=_oUpFiles.get(_aoFile.get("sId"));
if(!_oModel)
{
return;
}
_oModel.set(_aoFile.get());
_oModel.ossLog();
_oUpFiles.next(_oModel);
}}};
var _FTN_LIST=A.TE(['/cgi-bin/ftnExs_files?sid=$sid$&t=ftn.json&s=list&ef=js&listtype=$sListType$&up=$sOrder$&sorttype=$sSortType$&page=$page$&pagesize=$pagesize$&pagemode=more&pagecount=$pagecount$','$@$if($sListType$=="favorite")$@$','&pwpage=false&pathid=$sPathId$','$@$endif$@$','$@$if($sKeyword$)$@$','&keytext=$@$eval encodeURIComponent($sKeyword$)$@$','$@$endif$@$']);
var _qmFtnIndex=function(_aoListInfo,_aoUpFiles,_aoFiles){
var _oSelf=this;
_oSelf._moIndex=[];
_oSelf._moListInfo=_aoListInfo;
_oSelf._moUpFiles=_aoUpFiles;
_oSelf._moFiles=_aoFiles;
_oSelf._initEvent();
};
_qmFtnIndex.prototype={_initEvent:function(){
var _oSelf=this,_oUpFiles=_oSelf._moUpFiles,_oFiles=_oSelf._moFiles;
_oFiles.on("add",function(_aoModel){
var _oIndex=_oSelf._moIndex;
if(_aoModel.get("sPathId")!=_oSelf._moListInfo.sPathId)
{
return;
}
for(var i=0;i<=_oIndex.length-1;i++)
{
if(_oIndex[i].sColl=="Files")
{
break;
}
}
_oIndex.splice(i,0,{sFileId:_aoModel.get("sFileId"),bDirty:true,sColl:"Files"});
if(_oSelf._moListInfo.sSortType!="createtime")
{
_oSelf.dirtyAll();
}
});
_oUpFiles.on("change:sFileId",function(_aoModel){
if(_aoModel.get("sPathId")==_oSelf._moListInfo.sPathId)
{
_oSelf._moIndex.unshift({sFileId:_aoModel.get("sFileId"),bDirty:true,sColl:"UpFiles"});
}
});
function _fOnRemove(_aoModel)
{
ArrayEx.some(_oSelf._moIndex,function(_aoItem,_anIdx){
if(_aoItem.sFileId==_aoModel.get("sFileId"))
{
_oSelf._moIndex.splice(_anIdx,1);
return true;
}
});
}
;_oFiles.on("remove",_fOnRemove);
_oUpFiles.on("remove",_fOnRemove);
},_updateIndex:function(_aoData,_anPage,_anTotal){
var _oSelf=this,_oItem,_nLen,_nStartPos=_anPage*_PAGE_SIZE,_nEndPos=_nStartPos+_PAGE_SIZE*_PAGE_COUNT,_oIndex=_oSelf._moIndex,_nPrevPage=_anPage-1;
if(_aoData.length<_PAGE_SIZE*_PAGE_COUNT)
{
}
_oSelf._mbEmptyFile=_anTotal?false:true;
if(_aoData.length==0)
{
return;
}
if((_oItem=_oIndex[_nStartPos])&&_oItem.sFileId!=_aoData[0].sFileId)
{
for(var i=0;i<=_nStartPos-1;i++)
{
_oIndex[i].bDirty=true;
}
}
if((_oItem=_oIndex[_nEndPos])&&_oItem.sFileId!=_aoData[_aoData.length-1].sFileId)
{
for(var i=_nEndPos;i<=_oIndex.length-1;i++)
{
_oIndex[i].bDirty=true;
}
}
_oIndex.length=_anTotal;
[].splice.apply(_oIndex,[_nStartPos,_aoData.length].concat(_aoData));
_oSelf._moIndex=_oIndex;
},_toPageData:function(_anPage){
var _oSelf=this,_oListInfo=_oSelf._moListInfo,_oFiles=_oSelf._moFiles,_oIndex=_oSelf._moIndex,_nDirs=0,_oResult,_nPos=0,_bHasNotEmpty,_bHasEmpty,_bHasDirty;
_oResult=_oIndex.slice(_anPage*_PAGE_SIZE,(_anPage+1)*_PAGE_SIZE);
for(var i=0;i<_oResult.length;i++)
{
var _oItem=_oResult[i];
if(!_oItem)
{
_bHasEmpty=true;
break;
}
else{
_bHasNotEmpty=true;
_bHasDirty=_bHasDirty||_oResult[i].bDirty;
if(_oItem.sColl=="UpFiles")
{
var _oUpItem=_oUpFiles.getByFid(_oItem.sFileId);
if(!_oUpItem)
{
_bHasEmpty=true;
}
else{
_oResult[i]=_oUpItem.toTmplJSON();
if(_oUpItem.get("sStatus")=="uploading")
{
_nPos=i+1;
}
}
}
else{
var _oFile=_oFiles.get(_oItem.sFileId);
if(_oFile)
{
_oResult[i]=_oFile.toTmplJSON();
}
else{
debug("_toPageData toTmplJSON Err:"+_oItem.sFileId);
}
}
}
}
;if(_bHasEmpty||typeof _oSelf._mbEmptyFile=="undefined")
{
return;
}
else{
if(_anPage==0)
{
[].splice.apply(_oResult,[_nPos,0].concat(ArrayEx.map(_oUpFiles.getByNotInSvr(_oListInfo.sPathId)||[],function(_aoItem){
return _aoItem.toTmplJSON();
})));
if(_oListInfo.sListType=="favorite"&&_oListInfo.sPathId=="/")
{
var _oDirs=_oFavDirs.toTmplJSON();
_nDirs=_oDirs.length;
[].unshift.apply(_oResult,_oDirs);
}
}
return ({oListInfo:_oListInfo,bDirty:_bHasEmpty||_bHasDirty,nCurPage:_anPage,nFilePerPage:_PAGE_SIZE,nTotalFile:_oIndex.length,nTotalDir:_nDirs,nTotalPage:Math.ceil(_oIndex.length/_PAGE_SIZE),oFiles:[].slice.call(_oResult),nMigratStep:_oSelf._mnMigratStep||0});
}
},_fetchPageSvr:function(_anPage,_aoOptions){
var _oSelf=this,_fOnload=function(_abOK,_asParam){
var _oData;
try{
_oData=eval(_asParam)||{};
}
catch(e)
{
_oData={};
}
if(_abOK&&_oData.errcode=="0")
{
var _oFiles=_oSelf._moFiles,_oFileDatas=_oFiles.parse(_oData),_oIdxs;
_oData.migratStep&&(_oSelf._mnMigratStep=_oData.migratStep);
_oFiles.add(_oFileDatas,{silent:true,checkDup:true});
_oIdxs=ArrayEx.map(_oData.oFiles,function(_aoItem){
return ({sFileId:_aoItem.sFileId,sColl:_oFiles.get(_aoItem.sFileId)?"Files":"UpFiles"});
});
_oSelf._updateIndex(_oIdxs,_anPage,_oData.nTotal);
getTop().debug("toPageData");
_aoOptions.onsuccess(_oSelf._toPageData(_anPage));
_oSelf._mbFetching=false;
}
else{
_aoOptions.onerror(_oData.errcode,_oData.errmsg);
_oSelf._mbFetching=false;
}
};
if(!_anPage&&_oSelf._moListInfo.sListType=="self"&&typeof (_oSelf._mbFetching)=="undefined"&&_aoWin.QMFtnModels)
{
if(typeof _aoWin.QMFtnModels.vPreloadData=="string")
{
getTop().debug("prefetch cache1");
_fOnload(true,_aoWin.QMFtnModels.vPreloadData);
_aoWin.QMFtnModels.vPreloadData=true;
return;
}
else if(_aoWin.QMFtnModels.bPreFetching)
{
A.waitFor(function(){
return !!_aoWin.QMFtnModels.vPreloadData;
},function(_abIsOk){
if(_abIsOk)
{
getTop().debug("prefetch cache2");
_fOnload(true,_aoWin.QMFtnModels.vPreloadData);
_aoWin.QMFtnModels.vPreloadData=true;
}
else{
_fOnload(false);
_aoWin.QMFtnModels.vPreloadData=true;
}
},500,15000);
return;
}
}
_oSelf._mbFetching=true;
A.QMAjax.send(_FTN_LIST.replace(A.extend({sid:A.getSid(),pagesize:_PAGE_SIZE,pagecount:_PAGE_COUNT,page:_anPage},_oSelf._moListInfo)),{method:"GET",headers:{"If-Modified-Since":"0","Cache-Control":"no-cache, max-age=0"},onload:_fOnload});
},dirtyAll:function(){
var _oSelf=this;
if(_oSelf._moIndex.length==0)
{
_oSelf._mbEmptyFile=undefined;
}
else{
ArrayEx.forEach(_oSelf._moIndex,function(_aoItem){
_aoItem.bDirty=true;
});
}
},fetchPage:function(_anPage,_aoOptions){
var _oSelf=this,_oResult=_oSelf._toPageData(_anPage);
if(_oResult)
{
_oResult.bFromCache=true;
_aoOptions.onsuccess(_oResult);
if(_oResult.bDirty&&!_oUpFiles.isUploading(_oSelf._moListInfo.sListType=="favorite"?5:2))
{
getTop().debug("dirty and fetch......");
_oSelf._fetchPageSvr(_anPage,_aoOptions);
}
return;
}
_oSelf._fetchPageSvr(_anPage,_aoOptions);
}};
var _oIndexs={_moCaches:{},_set:function(_aoRegExp,_abDirty){
var _oCaches=this._moCaches;
for(var i in _oCaches)
{
if(_aoRegExp.test(i))
{
if(_abDirty)
{
_oCaches[i].dirtyAll();
}
else{
delete _oCaches[i];
}
}
}
},drop:function(_aoRegExp){
this._set(_aoRegExp);
},dirty:function(_aoRegExp){
this._set(_aoRegExp,true);
},get:function(_aoListInfo){
var _oSelf=this,_oIndex,_sIndex=[_aoListInfo.sListType,_aoListInfo.sPathId||"",_aoListInfo.sSortType,_aoListInfo.sOrder,_aoListInfo.sKeyword?"keyword-"+_aoListInfo.sKeyword:""].join(",");
if(_oIndex=_oSelf._moCaches[_sIndex])
{
return _oIndex;
}
else{
_aoListInfo=A.extend({},_aoListInfo);
if(_aoListInfo.sKeyword)
{
_oSelf.drop(/keyword-/);
}
if(/self/.test(_aoListInfo.sListType))
{
_oIndex=new _qmFtnIndex(_aoListInfo,_oUpFiles,_oFiles);
}
else if(/favorite/.test(_aoListInfo.sListType))
{
_oIndex=new _qmFtnIndex(_aoListInfo,_oUpFiles,_oFavFiles);
}
return _oSelf._moCaches[_sIndex]=_oIndex;
}
}};
var _oFtnModels={"UpFiles":_oUpFiles,"Files":_oFiles,"FavFiles":_oFavFiles,"FavDirs":_oFavDirs,"UserInfo":_oUserInfo};
_aoWin.QMFtnModels=A.extend(_aoWin.QMFtnModels||{},{oMgr:_qmFtnMgr,oIndexs:_oIndexs,oModels:_oFtnModels});
})(window,QMFtnAdaptor);
(function(a){
var g={},e=QMFtnModels.oModels.UpFiles;
var b,f=function(h){
var i=S("folder_ftn",getTop()),j=i.getElementsByTagName("span")[0];
if(j)
{
j.style.display=h?"inline-block":"none";
}
},c=function(){
return e.some(function(h){
return h.get("sStatus")=="uploading"&&/(ftn|list)/.test(h.get("sFrom"));
});
},d=function(){
f(c());
};
g.isUploading=c;
g.initBgUpIcon=function(){
if(b)
{
return;
}
b=true;
e.on("change:nPercent",d);
e.on("change:sStatus",d);
e.on("remove",d);
};
g.clearBgUpIcon=function(){
b=false;
f(false);
e.off("change:nPercent",d);
e.off("change:sStatus",d);
e.off("remove",d);
};
QMFtnModels.oFtnLogic=g;
})(QMFtnAdaptor);
